﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Common
{
    public class Sprite
    {
        public static SpriteBatch SpriteBatch { get; set; }
        public static  Game Game { set; get; }
        public static GraphicsDeviceManager Graphics { get; set; }
        public Texture2D Image;
        public string ImgUrl;
        /// <summary>
        /// 用于多实例共享图片
        /// </summary>
        public static Texture2D CommonImage;
        /// <summary>
        /// 精灵位图中每个图像的【宽，高】
        /// </summary>
        public Point FrameSize{ get; set; }
        /// <summary>
        /// 精灵位图中的行数/列数【列,行】
        /// </summary>
        public Point SheeftSize { get; set; }
        /// <summary>
        /// 精灵位图中当前将要绘制的行/列索引【列,行】
        /// </summary>
        public Point CurrentFrame { get; set; }
        /// <summary>
        /// 绘制的位置和尺寸
        /// </summary>
        public Rectangle DrawPosition=new Rectangle();

        public virtual void Draw(GameTime gameTime) { }

        public virtual void Update(GameTime gameTime) { }

        /// <summary>
        /// 加载精灵图片
        /// </summary>
        protected virtual void LoadPic()
        {
            if (this.Image == null)
                this.Image = Game.Content.Load<Texture2D>(this.ImgUrl);
        }
    }
}
